<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty price_format modifier plugin
 *
 * Type:     modifier<br>
 * Name:     price_format<br>
 * @param string
 * @param mix
 * @return string
 */
require_once 'core/config.php';
function smarty_function_show_image($params, &$smarty)
{
    $server=0; $width='max';
    foreach($params as $_key => $_val) {
        switch($_key){
            case 'url':
                $url = $_val;
                break;
            case 'server':
                $server = $_val;
                break;
            case 'width':
                $width = $_val;
                break;
        }
    }
    $width = Db_Image::getThumbStorage($width);

    if($server) {
        if(is_int($width)) {
            $path=IMAGE_PATH."/thumb_w/$width/$url";
        } else {
            $path=IMAGE_PATH.'/'.$url;
        }
    } else {
        $path=WEB_DIR.$url;
    }
    return $path;
}

